<?php
 /*
 * 1626cms 管理中心共用數據調用函數
 * ============================================================================
 * 版權所有: 1626網絡，并保留所有權利。
 * 網站地址: http://www.1626.com；
 * ----------------------------------------------------------------------------
 * 這不是一個自由軟件！您只能在不用于商業目的的前提下對程序代碼進行修改和
 * 使用；不允許對程序代碼以任何形式任何目的的再發布。
 * ============================================================================
*/
 if(!defined('IN_QISHI'))
 {
 	die('Access Denied!');
 }
//獲取文章分類(所有)
function get_article_category(){
global $db;
$sql = "select * from ".table('article_category')." where ParentID=0  ORDER BY category_order desc,id asc";
$category_list=$db->getall($sql);
for ($i = 0;$i < count($category_list); $i++)
{
$sqlf = "select * from ".table('article_category')." where ParentID=".$category_list[$i]['id']."  ORDER BY category_order desc,id asc";
$category_f=$db->getall($sqlf);
$category_list[$i]['category']=$category_f;
if(is_array($category_f))//獲取子分類下的末尾小類
{
$category_list_ending=array_reverse($category_f);
$category_list[$i]['ending']=$category_list_ending['0']['id'];
}
}
return $category_list;
}
//根據ID獲取文章分類(單個)
function get_article_category_one($val){
global $db;
$sql = "select * from ".table('article_category')." where id=".$val;
$article_category_one=$db->getone($sql);
return $article_category_one;
}
//獲取文章屬性分類
function get_article_property(){
global $db;
$sql = "select * from ".table('article_property')."  ORDER BY category_order desc,id asc";
$property_list=$db->getall($sql);
return $property_list;
}
//獲取文章頂級分類
function get_article_Parent(){
global $db;
$sql = "select * from ".table('article_category')." where ParentID=0  ORDER BY category_order desc,id asc";
$category_list=$db->getall($sql);
return $category_list;
}
//獲取目標父級分類下的小類
function get_article_Parent_list($val){
global $db;
$sql = "select * from ".table('article_category')." where ParentID=".$val."  ORDER BY category_order desc,id asc";
$category_list=$db->getall($sql);
return $category_list;
}
//獲取目標小類父級ID
function get_article_ParentID($val){
global $db;
$sql = "select * from ".table('article_category')." where id=".$val;
$category=$db->getone($sql);
$ParentID=$category['ParentID'];
return $ParentID;
}
//根據分類ID獲取分類名稱
function get_article_category_name($val){
global $db;
$sql = "select * from ".table('article_category')." where id=".$val;
$category=$db->getone($sql);
$categoryname=$category['categoryname'];
return $categoryname;
}
//根據屬性ID獲取屬性名稱
function get_article_property_name($val){
global $db;
$sql = "select * from ".table('article_property')." where id=".$val;
$category=$db->getone($sql);
$categoryname=$category['categoryname'];
return $categoryname;
}
//獲取文章
function get_news($offset, $perpage, $get_news_sql= ''){
global $db;
$row_arr = array();
if(isset($offset)&&!empty($perpage))
{
$limit=" LIMIT ".$offset.','.$perpage;
}
$result = $db->query("SELECT * FROM ".table('article').$get_news_sql." ORDER BY article_order DESC,id DESC ".$limit);
while($row = $db->fetch_array($result)){
$row['title']=cut_str($row['title'],18,0);
$tit_color = $row['tit_color'] ? "color:".$row['tit_color'].";" : '';
$tit_b = $row['tit_b']>0 ? "font-weight:bold;" : '';
$tit_style= $tit_color || $tit_b ? "style=\"".$tit_color.$tit_b."\""  : '';
$Small_img = $row['Small_img'] ? "<span style=\"color:#009900\">(圖)</span>" : '';
$url = $row['is_url']=="http://" ?url_rewrite('news-show',array('id0'=>$row['id'])) : $row['is_url'];
$row['url_title'] ="<a href=\"".$url."\" target=\"_blank\" ".$tit_style.">".$row['title']."</a> ".$Small_img."";
$row['type_id_name'] = get_article_category_name($row['type_id']);
$row['focos'] = get_article_property_name($row['focos']);
$row['title']=cut_str($row['title'],10,0);
$row_arr[] = $row;
}
return $row_arr;
}
?>
